package com.szdvte.news.service.impl;

import java.util.List;

import com.szdvte.news.bean.NewsCollect;
import com.szdvte.news.bean.Users;
import com.szdvte.news.dao.INewsCollectDao;
import com.szdvte.news.dao.IUserDao;
import com.szdvte.news.service.IUserService;

public class UserServiceImpl implements IUserService {
	private IUserDao userDao;
	private String msg;
	private INewsCollectDao newsCollectDao;
	@Override
	public String add(Users user) {
		if(userDao.count(user)>0){
			   msg = "已存在该用户,请重新输入用户名";
		}else{
			if(userDao.add(user)){
				msg = "注册成功";
			}else{
				msg = "注册失败";
			}
		}
		return msg;
	}

	@Override
	public Users login(Users user) {
		return userDao.login(user);
	}
	//
	public IUserDao getUserDao() {
		return userDao;
	}

	public void setUserDao(IUserDao userDao) {
		this.userDao = userDao;
	}

	public INewsCollectDao getNewsCollectDao() {
		return newsCollectDao;
	}

	public void setNewsCollectDao(INewsCollectDao newsCollectDao) {
		this.newsCollectDao = newsCollectDao;
	}

	//收藏
	@Override
	public boolean collect(NewsCollect collect) {
		return newsCollectDao.add(collect);
	}

	@Override
	public boolean update(Users user) {
		return userDao.update(user);
	}

	@Override
	public boolean delete(Users user) {
		return userDao.delete(user);
	}

	@Override
	public List<Users> select() {
		return userDao.select();
	}

	@Override
	public Users load(Users user) {
		return userDao.load(user);
	}
	
}
